﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Chrysalis.Services;

namespace ChrysalisTest.State
{
    public class CalculatorSessionState : IHasSessionState
    {
        // *** Properties ***

        public string Operator { get; set; }

        // *** IHasSessionState Methods ***

        void IHasSessionState.Initialize(object state)
        {
            CalculatorState sessionState = state as CalculatorState;

            if (sessionState == null)
                Operator = "+";
            else
                Operator = sessionState.Operator;
        }

        object IHasSessionState.SaveState()
        {
            return new CalculatorState()
                {
                    Operator = this.Operator
                };
        }

        // *** Sub-classes ***

        public class CalculatorState
        {
            public string Operator { get; set; }
        }
    }
}
